home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Shaders / TexturingAndModeling:AProceduralApproach / DPShaders / DPBlueMarble.sl < prev    next >
Encoding:
Text File  |  1995-03-22  |  1.0 KB  |  40 lines

  1. #include "proctext.h"
  2.  
  3. #define PALE_BLUE        color (0.25, 0.25, 0.35)
  4. #define MEDIUM_BLUE      color (0.10, 0.10, 0.30)
  5. #define DARK_BLUE        color (0.05, 0.05, 0.26)
  6. #define DARKER_BLUE      color (0.03, 0.03, 0.20)
  7. #define NNOISE           4
  8.  
  9. surface
  10. DPBlueMarble(
  11.     uniform float Ka = 1;
  12.     uniform float Kd = 0.8;
  13.     uniform float Ks = 0.2;
  14.     uniform float texturescale = 2.5;
  15.     uniform float roughness = 0.1;
  16.      )
  17. {
  18.     color Ct;
  19.     point NN;
  20.     point PP;
  21.     float i, f, marble;
  22.  
  23.     NN = normalize(faceforward(N, I));
  24.     PP = transform("shader", P) * texturescale;
  25.  
  26.     marble = 0; f = 1;
  27.     for (i = 0; i < NNOISE; i += 1) {
  28.         marble += snoise(PP * f)/f;
  29.         f *= 2.17;
  30.     }
  31.     Ct = color spline(clamp(2*marble + .75, 0, 1),
  32.               PALE_BLUE, PALE_BLUE,
  33.               MEDIUM_BLUE, MEDIUM_BLUE, MEDIUM_BLUE,
  34.               PALE_BLUE, PALE_BLUE, DARK_BLUE, DARK_BLUE,
  35.               DARKER_BLUE, DARKER_BLUE, PALE_BLUE, DARKER_BLUE);
  36.  
  37.     Ci = Os * (Ct * (Ka * ambient() + Kd * diffuse(NN))
  38.         + Ks * specular(NN, normalize(-I), roughness));
  39. }
  40.